<template>
  <div class="login">
    <div class="form">
      <div class="hr"></div>
      <router-link to="/home">
        <starport port="my-id">
          <avatar />
        </starport>
      </router-link>
      <div class="form-input">
        <input type="text" placeholder="请输入账号" />
        <input type="password" placeholder="未做验证，直接登录" />
      </div>
      <div class="form-button">
        <button>注册</button>
        <button @click="login">登录</button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
  import { ref } from 'vue'
  import router from '@/router'
  import avatar from '../components/avatar.vue'
  import { Starport } from 'vue-starport'
  import { setToken, saveRoutes } from '@/utils'

  const fakeToken = ref<{ token: string }>({ token: '' })
  const login = () => {
    fakeToken.value.token = '123.abc.789'
    setToken(JSON.stringify(fakeToken.value))
    saveRoutes()
    router.push({ path: '/' })
  }
</script>

<style lang="less" scoped>
  .login {
    height: 100vh;
    background-image: linear-gradient(0deg, #e8f5c6, #9fa5d5);
    display: flex;
    justify-content: center;
    align-items: center;

    .form {
      width: 400px;
      height: 250px;
      background-color: #fff;
      border-radius: 6px;
      box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px,
        rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      position: relative;

      .hr {
        height: 2px;
        width: 300px;
        background-color: #000;
        position: absolute;
        top: 50px;
      }
      a {
        z-index: 9;
      }
      div[port] {
        transition: all 2s;
        width: 80px;
        height: 80px;
        margin-bottom: 6px;
        border-radius: 50%;
        :deep(.avatar) {
          display: inline-block;
          width: 80px;
          height: 80px;
          margin-bottom: 6px;
          z-index: 9;

          img {
            width: 100%;
            height: 100%;
            border-radius: 50%;
          }
        }
      }

      .form-input {
        margin-bottom: 14px;
        input {
          height: 26px;
          display: block;
          border-radius: 6px;
          margin-bottom: 14px;
          border: 1px solid #000;
          &::placeholder {
            font-size: 13px;
            font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
          }
        }
      }
      .form-button {
        width: 37%;
        margin-bottom: 18px;
        display: flex;
        justify-content: space-between;
        button {
          width: 60px;
          height: 28px;
          border-radius: 4px;
          font-size: 14px;
          border: none;
          &:hover {
            background: rgba(107, 193, 233, 0.4);
          }
        }
      }
    }
  }
</style>
